# PQClient CMakeLists
# Author(s): xuming.Wong <xuming.Wong@gmail.com>

#-----------------------------------------------------------------------------
# DO NOT allow in-source builds.

if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "CMake generation for PQClient is not allowed within the source directory! 
Remove the CMakeCache.txt file and try again from another folder, e.g.: 
	rm CMakeCache.txt 
	cd ..
	mkdir PQClient_CMake_Out
	cd PQClient_CMake_Out
	cmake ../PQClient
")
endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})

cmake_minimum_required(VERSION 2.6)
project(PQClient)

if(WIN32)
  # This seems to break Xcode projects so definitely don't enable on Apple builds
  set(CMAKE_USE_RELATIVE_PATHS true)
  set(CMAKE_SUPPRESS_REGENERATION true)
endif()
if (MSVC)
  if (CMAKE_BUILD_TOOL STREQUAL "nmake")
    # set variable to state that we are using nmake makefiles
	set(NMAKE TRUE)
  endif ()
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast")
  # Enable intrinsics on MSVC in debug mode
  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Oi")
  if (CMAKE_CL_64)
    # Visual Studio bails out on debug builds in 64bit mode unless
	# this flag is set...
	set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj")
	set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /bigobj")
  endif ()
endif ()

if(WIN32)
	message(STATUS "On Windows System...")
	set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win32)
endif(WIN32)

set(OGRE_SOURCE_DIR  ${CMAKE_SOURCE_DIR}/dependency/ogre)
set(OGRE_BINARY_DIR ${CMAKE_BINARY_DIR})
set(OGRE_TEMPLATES_DIR ${OGRE_SOURCE_DIR}/CMake/Templates)
set(OGRE_WORK_DIR ${OGRE_BINARY_DIR})
# Specify build paths
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

set(OGRE_ARCHIVE_OUTPUT ${CMAKE_BINARY_DIR}/lib)
set(OGRE_LIBRARY_OUTPUT ${CMAKE_BINARY_DIR}/lib)
set(OGRE_RUNTIME_OUTPUT ${CMAKE_BINARY_DIR}/bin)

set(OGRE_DEPENDENCIES_DIR ${LIBDIR}/ogredependency)
	
# Include necessary submodules,Load macros.
# ---------------------------------------------------------
set(CMAKE_MODULE_PATH 
    ${CMAKE_SOURCE_DIR}/CMake
    ${CMAKE_SOURCE_DIR}/CMake/Utils
    ${CMAKE_SOURCE_DIR}/CMake/Packages
    ${CMAKE_SOURCE_DIR}/CMake/Templates
    )

include(CMakeDependentOption)
include(CheckCXXCompilerFlag)
include(MacroLogFeature)
include(OgreConfigTargets)
include(PreprocessorUtils)
include(PQMacros)
include(ConfigOgre3d)

# Redirect output files
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH  ${CMAKE_BINARY_DIR}/lib)
# Specify build paths
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
if (WIN32 OR APPLE)
  if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
    # We don't want to install in default system location, install is really for the SDK, so call it that
    set(CMAKE_INSTALL_PREFIX
	  "${CMAKE_BINARY_DIR}/sdk" CACHE PATH "OGRE install prefix" FORCE
    )
  endif (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
endif(WIN32 OR APPLE)

set(CMAKE_DEBUG_POSTFIX "_d")




#-----------------------------------------------------------------------------
# Libraries
file(WRITE ${CMAKE_BINARY_DIR}/cmake_libs.txt "")

configure_ogre_path(${CMAKE_SOURCE_DIR}/dependency/ogre)
# dependency
add_subdirectory(Dependency)
# client
add_subdirectory(Client)
